package czy.demo.config.shiro;

import org.apache.shiro.biz.web.filter.authc.listener.LogoutListener;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

/* 登出监听器 */
@Component
public class DefaultLogoutListener implements LogoutListener {

    private static final Logger logger = LoggerFactory.getLogger(DefaultLogoutListener.class);

    @Override
    public void beforeLogout(Subject subject, ServletRequest request, ServletResponse response) {
        logger.debug("用户"+subject.getPrincipal()+"即将登出");
    }

    @Override
    public void onFailure(Subject subject, Exception ex) {
        logger.error("用户"+subject.getPrincipal()+"登出失败",ex);
    }

    @Override
    public void onSuccess(Subject subject, ServletRequest request, ServletResponse response) {
        logger.debug("用户"+subject.getPrincipal()+"登出成功");
    }
}
